<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>商品详情 - 管理员后台</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        /* 保持与用户详情页相同的样式 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
        }

        :root {
            --primary: #2c3e50;
            --secondary: #34495e;
            --accent: #e74c3c;
            --light: #ecf0f1;
            --dark: #2c3e50;
            --success: #2ecc71;
            --info: #3498db;
            --gray: #95a5a6;
            --light-gray: #f5f7fa;
            --border: #e0e6ed;
            --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
            --hover-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
        }

        body {
            background-color: var(--light-gray);
            color: #333;
        }

        .admin-container {
            display: flex;
            min-height: 100vh;
        }

        /* 侧边栏样式 */
        .admin-sidebar {
            width: 250px;
            background: var(--primary);
            color: white;
            padding: 20px 0;
            position: fixed;
            height: 100vh;
            overflow-y: auto;
            z-index: 1000;
        }

        .admin-logo {
            text-align: center;
            padding: 20px 0;
            border-bottom: 1px solid var(--secondary);
            margin-bottom: 20px;
        }

        .admin-logo h2 {
            font-size: 1.5rem;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
        }

        .admin-menu {
            list-style: none;
            padding: 0;
        }

        .admin-menu li a {
            display: flex;
            align-items: center;
            padding: 15px 30px;
            color: var(--light);
            text-decoration: none;
            transition: all 0.3s;
            border-left: 4px solid transparent;
            font-size: 1rem;
        }

        .admin-menu li a:hover,
        .admin-menu li a.active {
            background: var(--secondary);
            border-left: 4px solid var(--accent);
        }

        .admin-menu li a i {
            width: 25px;
            text-align: center;
            margin-right: 12px;
            font-size: 1.1rem;
        }

        /* 主内容区样式 */
        .admin-content {
            flex: 1;
            padding: 30px;
            margin-left: 250px;
        }

        .admin-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
            padding-bottom: 20px;
            border-bottom: 1px solid var(--border);
        }

        .admin-header h1 {
            font-size: 1.8rem;
            color: var(--dark);
        }

        .admin-header .date-info {
            font-size: 1.1rem;
            color: var(--gray);
            background: var(--light);
            padding: 8px 15px;
            border-radius: 30px;
            box-shadow: var(--card-shadow);
        }

        /* 商品详情页特定样式 */
        .product-detail-container {
            background: white;
            border-radius: 12px;
            padding: 30px;
            box-shadow: var(--card-shadow);
            max-width: 900px;
            margin: 0 auto;
        }

        .product-info-header {
            text-align: center;
            margin-bottom: 30px;
            padding-bottom: 20px;
            border-bottom: 1px solid var(--border);
        }

        .product-info-header h2 {
            color: var(--dark);
            font-size: 1.8rem;
            margin-bottom: 10px;
        }

        .product-image-large {
            width: 250px;
            height: 250px;
            object-fit: cover;
            margin: 0 auto 25px;
            display: block;
            border: 5px solid var(--light);
            box-shadow: var(--card-shadow);
            border-radius: 8px;
        }

        .product-status-badge {
            display: inline-block;
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 0.9rem;
            font-weight: 600;
            margin-top: 5px;
        }

        .product-info-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }

        .product-info-table th, .product-info-table td {
            padding: 15px 20px;
            border-bottom: 1px solid var(--border);
            text-align: left;
        }

        .product-info-table th {
            width: 30%;
            font-weight: 600;
            color: var(--dark);
            background-color: var(--light-gray);
        }

        .product-info-table tr:last-child td {
            border-bottom: none;
        }

        .product-actions {
            display: flex;
            justify-content: center;
            gap: 15px;
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid var(--border);
        }

        .back-btn {
            background: var(--secondary);
            color: white;
            border: none;
            padding: 10px 25px;
            border-radius: 30px;
            cursor: pointer;
            transition: all 0.3s;
            font-size: 1rem;
            display: inline-flex;
            align-items: center;
            gap: 8px;
        }

        .back-btn:hover {
            background: var(--primary);
            transform: translateY(-2px);
            box-shadow: var(--hover-shadow);
        }

        .status-available {
            background-color: rgba(46, 204, 113, 0.15);
            color: var(--success);
        }

        .status-sold {
            background-color: rgba(231, 76, 60, 0.15);
            color: var(--accent);
        }

        .status-pending {
            background-color: rgba(241, 196, 15, 0.15);
            color: var(--warning);
        }

        .product-meta-info {
            color: var(--gray);
            font-size: 0.9rem;
            margin-top: 5px;
        }

        .product-description {
            padding: 15px;
            background-color: var(--light-gray);
            border-radius: 8px;
            margin-top: 15px;
            line-height: 1.6;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .product-info-table th,
            .product-info-table td {
                padding: 12px 15px;
                display: block;
                width: 100%;
            }

            .product-info-table th {
                background: none;
                padding-bottom: 5px;
            }

            .product-info-table td {
                padding-top: 5px;
                padding-bottom: 15px;
            }

            .product-image-large {
                width: 180px;
                height: 180px;
            }

            .admin-content {
                margin-left: 0;
                padding: 20px;
            }

            .admin-sidebar {
                width: 0;
                overflow: hidden;
            }
        }
    </style>
</head>
<body>
<div class="admin-container">
    <!-- 侧边栏 -->
    <div class="admin-sidebar">
        <div class="admin-logo">
            <h2><i class="fas fa-user-cog"></i> 管理员后台</h2>
        </div>
        <ul class="admin-menu">
            <li><a href="${pageContext.request.contextPath}/dashboard"
                   class="${activeTab == 'dashboard' ? 'active' : ''}"><i class="fas fa-chart-bar"></i> 数据统计</a></li>
            <li><a href="${pageContext.request.contextPath}/userManage"
                   class="${activeTab == 'user' ? 'active' : ''}"><i class="fas fa-users"></i> 用户统计</a></li>
            <li><a href="${pageContext.request.contextPath}/productManage"
                   class="${activeTab == 'product' ? 'active' : ''}"><i class="fas fa-box"></i> 商品统计</a></li>
            <li><a href="${pageContext.request.contextPath}/orderManege"
                   class="${activeTab == 'order' ? 'active' : ''}"><i class="fas fa-shopping-cart"></i> 订单统计</a></li>
            <li><a href="${pageContext.request.contextPath}/logout" id="logoutLink">
                <i class="fas fa-sign-out-alt"></i> 退出登录
            </a></li>
        </ul>
    </div>

    <!-- 主内容区 -->
    <div class="admin-content">
        <div class="admin-header">
            <h1>商品详情</h1>
            <div class="date-info">
                <i class="fas fa-calendar-alt"></i> <span id="current-date"></span>
            </div>
        </div>

        <div class="product-detail-container">
            <!-- 商品图片和基本信息头部 -->
            <div class="product-info-header">
                <img src="${pageContext.request.contextPath}/Market/${product.imageUrl}"
                     onerror="this.src='${pageContext.request.contextPath}/Market/default-product.webp'"
                     class="product-image-large" alt="商品图片">
                <h2>${product.title}</h2>
                <span class="product-status-badge
                    ${product.status == 1 ? 'status-available' :
                      product.status == 2 ? 'status-sold' : 'status-pending'}">
                    <i class="fas ${product.status == 1 ? 'fa-check-circle' :
                                   product.status == 2 ? 'fa-check' : 'fa-clock'}"></i>
                    ${product.status == 1 ? '在售中' :
                            product.status == 2 ? '已售出' : '已下架'}
                </span>
                <div class="product-meta-info">
                    商品ID: ${product.productId} | 上架时间: <fmt:formatDate value="${product.createTime}"
                                                                       pattern="yyyy-MM-dd"/>
                </div>
            </div>

            <!-- 商品详细信息表格 -->
            <table class="product-info-table">
                <tr>
                    <th>商品分类</th>
                    <td>
                        <c:forEach items="${categories}" var="category">
                            <c:if test="${category.categoryId == product.categoryId}">
                                ${category.categoryName}
                            </c:if>
                        </c:forEach>
                    </td>
                </tr>
                <tr>
                    <th>售价</th>
                    <td>¥<fmt:formatNumber value="${product.price}" pattern="0.00"/></td>
                </tr>
                <tr>
                    <th>原价</th>
                    <td>¥<fmt:formatNumber value="${product.originalPrice}" pattern="0.00"/></td>
                </tr>
                <tr>
                    <th>成色</th>
                    <td>${product.conditionLevel}成新</td>
                </tr>
                <tr>
                    <th>卖家信息</th>
                    <td>
                        <c:if test="${not empty seller}">
                            ${seller.username} <br>
                            联系方式: ${seller.phone}
                        </c:if>
                    </td>
                </tr>
                <tr>
                    <th>上架时间</th>
                    <td><fmt:formatDate value="${product.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                </tr>
                <tr>
                    <th>最后更新时间</th>
                    <td><fmt:formatDate value="${product.updateTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                </tr>
            </table>

            <!-- 商品描述 -->
            <div class="product-description">
                <h3>商品描述</h3>
                <p>${product.description}</p>
            </div>

            <!-- 操作按钮 -->
            <div class="product-actions">
                <button class="back-btn" onclick="window.history.back()">
                    <i class="fas fa-arrow-left"></i> 返回列表
                </button>
            </div>
        </div>
    </div>
</div>

<script>
    // 日期显示脚本
    function updateCurrentTime() {
        const now = new Date();
        const options = {
            year: 'numeric',
            month: '2-digit',
            day: '2-digit',
            weekday: 'long',
            hour: '2-digit',
            minute: '2-digit',
            second: '2-digit',
            hour12: false
        };
        document.getElementById('current-date').textContent = now.toLocaleString('zh-CN', options);
    }

    updateCurrentTime();
    setInterval(updateCurrentTime, 1000);
</script>
</body>
</html>